<template>
  <div>
      <el-select v-model="user"  :style="{width: '100%'}" clearable placeholder="请选择人员信息" @change="getUserId" >
          <el-option v-for="item in users" :key="item.userId" :label="item.userName" :value="item.userId"></el-option>
      </el-select>
  </div>
</template>

<script>
import { listUser } from "@/api/system/user";
export default {
  name: "Order",
  props:["userId"],
  data() {
    return {
      user:this.userId,
      // 用户信息列表
      users:[],
    };
  },
  created() {
    this.getUserList();
  },
  methods: {
    // 获取用户信息列表
    getUserList(){
      listUser().then(({data}) => {
        this.users = data.records;
      })
    },
    // 向父组件发送选中值
    getUserId(val){
      this.$emit("getUserId", val);
    }
  }
};
</script>
